package poo.file;
import java.io.*;

public class Crittografia {

	static byte crittografa(int d, int chiave){
		return (byte)(d+chiave);
	}
	
	public static void main(String[] args) throws IOException {

		if(args.length==0){
			System.out.println("Attesa chiave");
			System.exit(-1);
		}
		int chiave = Integer.parseInt(args[0]); //assunta in valore assoluto >=3
		InputStream source=new FileInputStream("C:\\Users\\Pa\\Documents\\source.dat");
		OutputStream dest=new FileOutputStream("C:\\Users\\Pa\\Documents\\dest.dat");
		int dato;
		for(;;){
			dato=source.read();
			if(dato==-1) break;
			dest.write(crittografa(dato, chiave));
		}
		source.close();
		dest.close();
	}

}
